﻿using System;
using System.Collections.Generic;
using System.Text;

using HyEduOnline.Entities;
using HyEduOnline.Data;
namespace HyEduOnline.Server.Admin
{
	/// <summary>
	///		此用于处理表对象 'tb_DeanStuSelCourse' 
	/// </summary>
	/// <remarks>
	/// 	此结构由代码由TMS使用代码生成器书写生成，请不要直接修改.
	///注意:此代码可能和同名的视图生成一个完整对象
	/// </remarks>
	

	
	public partial class DeanStuSelCourseBaseDAO
	{
		
	#region 表生成代码
		protected int TotalCount = -1;
		
		
		/// <summary>
       
		
		/// <summary>
        /// 取所有的对象,例如TList<???>
        /// </summary>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, true)]
        public  TList<TbDeanStuSelCourse> GetAll()
        {
            return DataRepository.Provider.TbDeanStuSelCourseProvider.GetAll();
        }

		/// <summary>
        /// 通过id来取对象
        /// </summary>
        /// <param name="id">对象的ID</param>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public TbDeanStuSelCourse GetByID(int id)
        {
            return DataRepository.Provider.TbDeanStuSelCourseProvider.GetById(id);
        }

        /// <summary>
        /// 条件查询分页
        /// </summary>
        /// <param name="whereClause">条件</param>
        /// <param name="startRowIndex">起始值</param>
        /// <param name="maximumRows">每页的最大值</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public  TList<TbDeanStuSelCourse> GetByPage(string whereClause, int startRowIndex, int maximumRows)
        {

            return DataRepository.Provider.TbDeanStuSelCourseProvider.GetPaged(whereClause, "ID", (int)startRowIndex / maximumRows, maximumRows, out TotalCount);

        }
		
		 /// <summary>
        ///支持Ext的分页查询,表
        /// </summary>
        /// <param name="whereClause">查询条件</param>
        /// <param name="start">起始位置</param>
        /// <param name="limit">最大条数</param>
        /// <param name="sort">排序列</param>
        /// <param name="dir">排序方向("DESC","ASC")</param>
        /// <param name="count">取得记录数</param>
        /// <returns>TList<???></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public  TList<TbDeanStuSelCourse>  GetByPage(string whereClause, int start, int limit, string sort, string dir, out int count)
        {
            string sOrder = "";
            if (! String.IsNullOrEmpty(sort ) && sort.ToUpper() != "ID")
            {
                sOrder = sort.Insert(1, "_") + " " + dir;
            }
            else
            {
                 if (sort != null && sort.ToLower() == "id") sOrder = sort + " " + dir;
            }
			
            return DataRepository.Provider.TbDeanStuSelCourseProvider.GetPaged(whereClause, sOrder, (int)start / limit, limit, out count);
        }
		
		
		
        /// <summary>
        /// 分页查询计数
        /// </summary>
        /// <param name="whereClause">查询调价</param>
		/// <param name="startRowIndex">起始值</param>
        /// <param name="maximumRows">每页的最大值</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public int GetCount(string whereClause, int startRowIndex, int maximumRows)
        {
            if (TotalCount != -1)
            {
                return TotalCount;
            }
            else
            {
                DataRepository.Provider.TbDeanStuSelCourseProvider.GetTotalItems(whereClause, out TotalCount);
                return TotalCount;
            }
        }
		
		
		
		
		/// <summary>
        /// 更新对象，传入的是一个对象
        /// </summary>
        /// <param name="item">需要更新的对象</param>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Update, true)]
        public bool Update(TbDeanStuSelCourse item)
        {
            return DataRepository.Provider.TbDeanStuSelCourseProvider.Update(item);
        }
		
		/// <summary>
        /// 更新对象，传入的是一个Tlist对象
        /// </summary>
        /// <param name="items">需要更新的TList对象</param>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Update, false)]
        public int Update(TList<TbDeanStuSelCourse> items)
        {
            return DataRepository.Provider.TbDeanStuSelCourseProvider.Update(items);
        }
		
		
		
		/// <summary>
        /// 更新对象，传入的是此对象的多个属性，属性个数为  15
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Update, false)]
        public bool Update(
		System.String SStuNo, System.String SStuName, 
			System.Int32? ISex, System.Int32? ICourseId, System.String SCourseName, 
			System.String SCouseCode, System.Int32? ITeacherId, System.String STeacherCode, 
			System.String STeacherName, System.Int32? IDeanOpenCourseId, System.String STermName, 
			System.Int32? ITermId, System.String SClassCode, System.String SClassName, 
			System.Int32? IClassId, System.Int64 Id
		)
        {
			
			TbDeanStuSelCourse item =new TbDeanStuSelCourse();
			
			
			

			item.SStuNo = SStuNo;
			item.SStuName = SStuName;
			item.ISex = ISex;
			item.ICourseId = ICourseId;
			item.SCourseName = SCourseName;
			item.SCouseCode = SCouseCode;
			item.ITeacherId = ITeacherId;
			item.STeacherCode = STeacherCode;
			item.STeacherName = STeacherName;
			item.IDeanOpenCourseId = IDeanOpenCourseId;
			item.STermName = STermName;
			item.ITermId = ITermId;
			item.SClassCode = SClassCode;
			item.SClassName = SClassName;
			item.IClassId = IClassId;
			
			
			item.Id = Id;
			
            return DataRepository.Provider.TbDeanStuSelCourseProvider.Update(item);
        }
		
		
		/// <summary>
        /// 通过ID来删除对象
        /// </summary>
        /// <param name="id">对象ID</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete, true)]
        public int Del(string ids)
        {
		
			TList<TbDeanStuSelCourse> tmpList= GetByPage("id in ("+ids+")",0,int.MaxValue);
			

            return Del(tmpList);

        }
		
		
		/// <summary>
        /// 通过ID来删除对象
        /// </summary>
        /// <param name="id">对象ID</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete, true)]
        public bool Del(int id)
        {

            return DataRepository.Provider.TbDeanStuSelCourseProvider.Delete(id);

        }
		
		/// <summary>
        /// 通过对象删除记录
        /// </summary>
        /// <param name="item">对象</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete, false)]
        public bool Del(TbDeanStuSelCourse item)
        {

            return DataRepository.Provider.TbDeanStuSelCourseProvider.Delete(item);

        }
		
		/// <summary>
        /// 通过对象删除记录
        /// </summary>
        /// <param name="items">需删除的TList对象</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete, false)]
        public int Del(TList<TbDeanStuSelCourse> items)
        {

            return DataRepository.Provider.TbDeanStuSelCourseProvider.Delete(items);

        }
		
		
		/// <summary>
        /// 插入一个对象
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
		 [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Insert, true)]
        public bool Insert(TbDeanStuSelCourse item)
        {
            return DataRepository.Provider.TbDeanStuSelCourseProvider.Insert(item);
        }
		
		/// <summary>
        /// 插入一个TList对象
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
		 [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Insert, false)]
        public int Insert(TList<TbDeanStuSelCourse> items)
        {
            return DataRepository.Provider.TbDeanStuSelCourseProvider.Insert(items);
        }
        
		/// <summary>
        /// 更具条件查找
        /// </summary>
        /// <param name="whereClause">需要查找的条件</param>
        /// <returns>TList对象</returns>
        public TList<TbDeanStuSelCourse> GetByCondition(string whereClause)
        {
            return DataRepository.Provider.TbDeanStuSelCourseProvider.Find(whereClause);
        }
		
		


#endregion 表生成代码

    #region 兼容代码



		 /// <summary>
        ///兼容查询
        /// </summary>
        /// <param name="whereClause">查询条件</param>
        /// <param name="start">起始位置</param>
        /// <param name="limit">最大条数</param>
        /// <param name="sort">排序列</param>
        /// <param name="dir">排序方向("DESC","ASC")</param>
        /// <param name="count">取得记录数</param>
        /// <returns>TList<???></returns>
		
        public  TList<TbDeanStuSelCourse>  getByPageDataBase( int start, int limit, string sort,string whereClause, out int count)
        {
		///(0, 10000, "I_Level ASC,I_Group ASC,ID ASC", "I_Type=1 and id<>1", out count);
            string sOrder = "";
            string[] sortTmps=sort.Split(' ');

            if (!String.IsNullOrEmpty(sort) && sortTmps[0].ToUpper() != "ID")
            {

                sOrder = sort.Insert(1, "_") ;
            }
            else
            {
                 if (sort != null && sort.ToLower() == "id") sOrder = sort + " " ;
            }
			
            return DataRepository.Provider.TbDeanStuSelCourseProvider.GetPaged(whereClause, sOrder, start , limit, out count);
        }


 /// 取所有的对象,例如TList<???>
        /// </summary>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, true)]
        public  TList<TbDeanStuSelCourse> findAll()
        {
            return DataRepository.Provider.TbDeanStuSelCourseProvider.GetAll();
        }
		

		 public  TList<TbDeanStuSelCourse> findByProperty(String propertyName, Object value)
        {
            TList<TbDeanStuSelCourse> tmpList = new TList<TbDeanStuSelCourse>();
            try
            {

                string whereC = "";
				 string FirC=propertyName.Substring(0,1);
                if (FirC != "I" || FirC != "F")
                {
                
                    value="'"+value.ToString()+"'";
                }
				
                if (!String.IsNullOrEmpty(propertyName) && propertyName.ToUpper() != "ID")
                {
                    whereC = propertyName.Insert(1, "_") + "= " + value.ToString();
                }
                else
                {
                    whereC = propertyName + "= " + value.ToString();
                }

              
                tmpList = GetByPage(whereC,0,int.MaxValue);
                return tmpList;
            }
            catch (Exception re)
            {
                throw re;
            }
        }//end for findByProperty
		
		
		
		  /*
       *get the Object through SStuNo
       */
	public IList<TbDeanStuSelCourse> findBySStuNo(Object _SStuNo)
        {
            return findByProperty("SStuNo",_SStuNo);
         }
		
		
		  /*
       *get the Object through SStuName
       */
	public IList<TbDeanStuSelCourse> findBySStuName(Object _SStuName)
        {
            return findByProperty("SStuName",_SStuName);
         }
		
		
		  /*
       *get the Object through ISex
       */
	public IList<TbDeanStuSelCourse> findByISex(Object _ISex)
        {
            return findByProperty("ISex",_ISex);
         }
		
		
		  /*
       *get the Object through ICourseId
       */
	public IList<TbDeanStuSelCourse> findByICourseId(Object _ICourseId)
        {
            return findByProperty("ICourseId",_ICourseId);
         }
		
		
		  /*
       *get the Object through SCourseName
       */
	public IList<TbDeanStuSelCourse> findBySCourseName(Object _SCourseName)
        {
            return findByProperty("SCourseName",_SCourseName);
         }
		
		
		  /*
       *get the Object through SCouseCode
       */
	public IList<TbDeanStuSelCourse> findBySCouseCode(Object _SCouseCode)
        {
            return findByProperty("SCouseCode",_SCouseCode);
         }
		
		
		  /*
       *get the Object through ITeacherId
       */
	public IList<TbDeanStuSelCourse> findByITeacherId(Object _ITeacherId)
        {
            return findByProperty("ITeacherId",_ITeacherId);
         }
		
		
		  /*
       *get the Object through STeacherCode
       */
	public IList<TbDeanStuSelCourse> findBySTeacherCode(Object _STeacherCode)
        {
            return findByProperty("STeacherCode",_STeacherCode);
         }
		
		
		  /*
       *get the Object through STeacherName
       */
	public IList<TbDeanStuSelCourse> findBySTeacherName(Object _STeacherName)
        {
            return findByProperty("STeacherName",_STeacherName);
         }
		
		
		  /*
       *get the Object through IDeanOpenCourseId
       */
	public IList<TbDeanStuSelCourse> findByIDeanOpenCourseId(Object _IDeanOpenCourseId)
        {
            return findByProperty("IDeanOpenCourseId",_IDeanOpenCourseId);
         }
		
		
		  /*
       *get the Object through STermName
       */
	public IList<TbDeanStuSelCourse> findBySTermName(Object _STermName)
        {
            return findByProperty("STermName",_STermName);
         }
		
		
		  /*
       *get the Object through ITermId
       */
	public IList<TbDeanStuSelCourse> findByITermId(Object _ITermId)
        {
            return findByProperty("ITermId",_ITermId);
         }
		
		
		  /*
       *get the Object through SClassCode
       */
	public IList<TbDeanStuSelCourse> findBySClassCode(Object _SClassCode)
        {
            return findByProperty("SClassCode",_SClassCode);
         }
		
		
		  /*
       *get the Object through SClassName
       */
	public IList<TbDeanStuSelCourse> findBySClassName(Object _SClassName)
        {
            return findByProperty("SClassName",_SClassName);
         }
		
		
		  /*
       *get the Object through IClassId
       */
	public IList<TbDeanStuSelCourse> findByIClassId(Object _IClassId)
        {
            return findByProperty("IClassId",_IClassId);
         }
		
		
#endregion 兼容代码

    

    #region 自定义代码


		
#endregion 自定义代码



    #region 视图代码

    protected int VWTotalCount = -1;


    /// <summary>
    /// 取所有的对象,例如VList<???>
    /// </summary>
    /// <returns></returns>
    [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, true)]
    public VList<VwDeanStuSelCourse> GetVWAll()
    {
        return DataRepository.Provider.VwDeanStuSelCourseProvider.GetAll();
    }


    /// <summary>
    /// 条件查询分页
    /// </summary>
    /// <param name="whereClause">条件</param>
    /// <param name="startRowIndex">起始值</param>
    /// <param name="maximumRows">每页的最大值</param>
    /// <returns></returns>
    [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
    public VList<VwDeanStuSelCourse> GetByPageVW(string whereClause, int startRowIndex, int maximumRows)
    {
        return DataRepository.Provider.VwDeanStuSelCourseProvider.Get(whereClause, "ID", (int)startRowIndex / maximumRows, maximumRows, out VWTotalCount);

    }
    /// <summary>
    ///支持Ext的分页查询,视图
    /// </summary>
    /// <param name="whereClause">查询条件</param>
    /// <param name="start">起始位置</param>
    /// <param name="limit">最大条数</param>
    /// <param name="sort">排序列</param>
    /// <param name="dir">排序方向("DESC","ASC")</param>
    /// <param name="count">取得记录数</param>
    /// <returns>VList<???></returns>
    [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
    public VList<VwDeanStuSelCourse> GetByPageVW(string whereClause, int start, int limit, string sort, string dir, out int count)
    {
        string sOrder = "";
        if (sort != null && sort != "Id")
        {
            sOrder = sort.Insert(1, "_") + " " + dir;
        }
        else
        {
            if (sort == "Id") sOrder = sort + " " + dir;
        }
        return DataRepository.Provider.VwDeanStuSelCourseProvider.Get(whereClause, sOrder, (int)start / limit, limit, out count);
    }

    /// <summary>
    /// 分页查询计数
    /// </summary>
    /// <param name="whereClause"></param>
    /// <returns></returns>
    [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
    public int GetVWCount(string whereClause, int startRowIndex, int maximumRows)
    {
        if (VWTotalCount != -1)
        {
            return VWTotalCount;
        }
        else
        {
            DataRepository.Provider.VwDeanStuSelCourseProvider.GetTotalItems(whereClause, out VWTotalCount);
            return VWTotalCount;
        }
    }

    /// <summary>
    /// 更具条件查找
    /// </summary>
    /// <param name="whereClause">需要查找的条件</param>
    /// <returns>VList对象</returns>
    [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
    public VList<VwDeanStuSelCourse> GetVWByCondition(string whereClause)
    {
        return GetByPageVW(whereClause, 0, int.MaxValue);
    }


    /// <summary>
    /// 通过id来取对象
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public VwDeanStuSelCourse GetByVWID(int id)
    {

        VwDeanStuSelCourse Item = null;

        VList<VwDeanStuSelCourse> vwList = GetByPageVW("ID=" + id.ToString(), 0, 1);
        if (vwList.Count > 0)
        {
            Item = vwList[0];
        }
        return Item;

    }




    #endregion 视图代码
	}
}